﻿
Ext.namespace('FantastPlatform', 'FantastPlatform.UI');


FantastPlatform.UI.FlowLevelForm = function (config) {
    Ext.apply(this, config);
 
   
    
    this.items = [{
        layout: 'column',
        border: false,
        labelSeparator: '：',
        items: [{
                    columnWidth: 1,
                    border: false,
                    layout: 'form',
                    items: [new Ext.form.TextField({
                        fieldLabel: '预案名称',
                        name: 'Name',
                        allowBlank: false,
                        blankText: " 预案名称不能为空" ,
                         anchor: '90%'                      
                    })]
                }, {
                    columnWidth: 1,
                    border: false,
                    layout: 'form',
                    items: [new Ext.form.TextField({
                        fieldLabel: '梯队数量',
                        name: 'EchelonNumber',
                        allowBlank: false,                       
                        regex: /^(\d{1,1})$/,
                        regexText: '只能输入0-9',
                        blankText: " 梯队数量不能为空"                      
                    })]
                },  {
                    columnWidth: 1,
                    border: false,
                    layout: 'form',
                    items: [new Ext.form.TextField({
                        fieldLabel: '指挥领导',
                        name: 'Leader',
                        allowBlank: false,
                        blankText: " 指挥领导不能为空" ,                  
                         anchor: '90%'
                    })]
                }, {
                    columnWidth: 1,
                    border: false,
                    layout: 'form',
                    items: [new Ext.form.TextArea({
                        fieldLabel: '适用范围',
                        name: 'Range',
                        allowBlank: false,
                        blankText: " 适用范围不能为空",
                        height: 100,
                        anchor: '90%'
                    })]
                }, {
                    columnWidth: 1,
                    border: false,
                    layout: 'form',
                    items: [new Ext.form.TextArea({
                        fieldLabel: '要求',
                        name: 'Require',
                        allowBlank: false,
                        blankText: " 要求不能为空",
                        height: 100,
                        anchor: '90%'
                    })]
                }]
    }];

    FantastPlatform.UI.FlowLevelForm.superclass.constructor.call(this, {
        bodyStyle: 'padding:5px',
        collapsible: true,
        labelAlign: 'right',
        autoScroll: true,
        border: false
    });
};

Ext.extend(FantastPlatform.UI.FlowLevelForm, Ext.form.FormPanel, {
    onRender: function (ct, position) {
        FantastPlatform.UI.FlowLevelForm.superclass.onRender.call(this, ct, position);
        if (this.Id && this.Id != 0) {
            this.add(new Ext.form.Hidden({ name: 'Id', value: this.Id }));
            var Form = this.form;
            this.form.load({
                url: '../Service/FlowFileViewService.aspx?Action=Get',
                params: { id: this.Id },
                waitMsg: '正在读取数据...',
                waitTitle: '请稍后...',
                failure: function (form, action) {
                    if (action.failureType != 'client') {
                        showErrorMessage('操作失败', action.result.message, '');
                    }
                },
                success: function (form, action) {

//                    if (form.getValues().CreatePoliceManNumber != policemanNumber && AdminI != "True") {
//                        Ext.getCmp('saveNotice').setDisabled(true);
//                        Ext.getCmp('cancelNotice').setDisabled(true);
//                        //                        Ext.getCmp('addDetail').setDisabled(true);
//                        //                        Ext.getCmp('ChangeCar').setDisabled(true);
//                    }
                }
            });
//            Ext.Ajax.request({
//                method: 'post',
//                url: "../Service/FlowFileViewService.aspx?Action=GetLeadersByFlowFileId",
//                params: { id: this.Id },
//                success: function (request, options) {
//                    // 服务器返回json形式的结果                                          
//                    var reText = request.responseText;
//                    var reTextObj = Ext.util.JSON.decode(reText);
//                    if (eval(reTextObj.success)) {
//                        Form.findField('Leaders').setValue(reTextObj.message);
//                    }
//                }
//            });
        }
    }
});

